<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>texeditor.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_ui_equation_texeditor.js.html">texeditor.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2009 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>goog.provide(&#39;goog.ui.equation.TexEditor&#39;);
<a name="line16"></a>
<a name="line17"></a>goog.require(&#39;goog.dom&#39;);
<a name="line18"></a>goog.require(&#39;goog.ui.Component&#39;);
<a name="line19"></a>goog.require(&#39;goog.ui.equation.ImageRenderer&#39;);
<a name="line20"></a>goog.require(&#39;goog.ui.equation.TexPane&#39;);
<a name="line21"></a>
<a name="line22"></a>
<a name="line23"></a>
<a name="line24"></a>/**
<a name="line25"></a> * User interface for equation editor plugin.
<a name="line26"></a> * @constructor
<a name="line27"></a> * @param {Object} context The context that this Tex editor runs in.
<a name="line28"></a> * @param {string} helpUrl URL pointing to help documentation.
<a name="line29"></a> * @param {goog.dom.DomHelper=} opt_domHelper DomHelper to use.
<a name="line30"></a> * @extends {goog.ui.Component}
<a name="line31"></a> */
<a name="line32"></a>goog.ui.equation.TexEditor = function(context, helpUrl, opt_domHelper) {
<a name="line33"></a>  goog.ui.Component.call(this, opt_domHelper);
<a name="line34"></a>
<a name="line35"></a>  /**
<a name="line36"></a>   * The context that this Tex editor runs in.
<a name="line37"></a>   * @type {Object}
<a name="line38"></a>   * @private
<a name="line39"></a>   */
<a name="line40"></a>  this.context_ = context;
<a name="line41"></a>
<a name="line42"></a>  /**
<a name="line43"></a>   * A URL pointing to help documentation.
<a name="line44"></a>   * @type {string}
<a name="line45"></a>   * @private
<a name="line46"></a>   */
<a name="line47"></a>  this.helpUrl_ = helpUrl;
<a name="line48"></a>};
<a name="line49"></a>goog.inherits(goog.ui.equation.TexEditor, goog.ui.Component);
<a name="line50"></a>
<a name="line51"></a>
<a name="line52"></a>/**
<a name="line53"></a> * The TeX editor pane.
<a name="line54"></a> * @type {goog.ui.equation.TexPane}
<a name="line55"></a> * @private
<a name="line56"></a> */
<a name="line57"></a>goog.ui.equation.TexEditor.prototype.texPane_ = null;
<a name="line58"></a>
<a name="line59"></a>
<a name="line60"></a>/** @override */
<a name="line61"></a>goog.ui.equation.TexEditor.prototype.createDom = function() {
<a name="line62"></a>  goog.base(this, &#39;createDom&#39;);
<a name="line63"></a>  this.createDom_();
<a name="line64"></a>};
<a name="line65"></a>
<a name="line66"></a>
<a name="line67"></a>/**
<a name="line68"></a> * Creates main editor contents.
<a name="line69"></a> * @private
<a name="line70"></a> */
<a name="line71"></a>goog.ui.equation.TexEditor.prototype.createDom_ = function() {
<a name="line72"></a>  var contentElement = this.getElement();
<a name="line73"></a>  this.texPane_ = new goog.ui.equation.TexPane(this.context_,
<a name="line74"></a>      this.helpUrl_, this.dom_);
<a name="line75"></a>  this.addChild(this.texPane_);
<a name="line76"></a>  this.texPane_.render(contentElement);
<a name="line77"></a>  this.texPane_.setVisible(true);
<a name="line78"></a>};
<a name="line79"></a>
<a name="line80"></a>
<a name="line81"></a>/** @override */
<a name="line82"></a>goog.ui.equation.TexEditor.prototype.decorateInternal = function(element) {
<a name="line83"></a>  this.setElementInternal(element);
<a name="line84"></a>  this.createDom_();
<a name="line85"></a>};
<a name="line86"></a>
<a name="line87"></a>
<a name="line88"></a>/**
<a name="line89"></a> * Returns the encoded equation.
<a name="line90"></a> * @return {string} The encoded equation.
<a name="line91"></a> */
<a name="line92"></a>goog.ui.equation.TexEditor.prototype.getEquation = function() {
<a name="line93"></a>  return this.texPane_.getEquation();
<a name="line94"></a>};
<a name="line95"></a>
<a name="line96"></a>
<a name="line97"></a>/**
<a name="line98"></a> * Parse an equation and draw it.
<a name="line99"></a> * Clears any previous displayed equation.
<a name="line100"></a> * @param {string} equation The equation text to parse.
<a name="line101"></a> */
<a name="line102"></a>goog.ui.equation.TexEditor.prototype.setEquation = function(equation) {
<a name="line103"></a>  this.texPane_.setEquation(equation);
<a name="line104"></a>};
<a name="line105"></a>
<a name="line106"></a>
<a name="line107"></a>/**
<a name="line108"></a> * @return {string} The html code to embed in the document.
<a name="line109"></a> */
<a name="line110"></a>goog.ui.equation.TexEditor.prototype.getHtml = function() {
<a name="line111"></a>  return goog.ui.equation.ImageRenderer.getHtml(this.getEquation());
<a name="line112"></a>};
<a name="line113"></a>
<a name="line114"></a>
<a name="line115"></a>/**
<a name="line116"></a> * Checks whether the current equation is valid and can be used in a document.
<a name="line117"></a> * @return {boolean} Whether the equation valid.
<a name="line118"></a> */
<a name="line119"></a>goog.ui.equation.TexEditor.prototype.isValid = function() {
<a name="line120"></a>  return goog.ui.equation.ImageRenderer.isEquationTooLong(
<a name="line121"></a>      this.getEquation());
<a name="line122"></a>};
<a name="line123"></a>
<a name="line124"></a>
<a name="line125"></a>/**
<a name="line126"></a> * Sets the visibility of the editor.
<a name="line127"></a> * @param {boolean} visible Whether the editor should be visible.
<a name="line128"></a> */
<a name="line129"></a>goog.ui.equation.TexEditor.prototype.setVisible = function(visible) {
<a name="line130"></a>  this.texPane_.setVisible(visible);
<a name="line131"></a>};
<a name="line132"></a>
<a name="line133"></a>
<a name="line134"></a>/** @override */
<a name="line135"></a>goog.ui.equation.TexEditor.prototype.disposeInternal = function() {
<a name="line136"></a>  if (this.texPane_) {
<a name="line137"></a>    this.texPane_.dispose();
<a name="line138"></a>  }
<a name="line139"></a>  this.context_ = null;
<a name="line140"></a>  goog.base(this, &#39;disposeInternal&#39;);
<a name="line141"></a>};
</pre>


</body>
</html>
